<script lang="ts" setup>
import { h, onMounted,computed } from "vue"
import { useTheme } from "@/hooks/useTheme"
import { ElNotification } from "element-plus"
import zhCn from "element-plus/lib/locale/lang/zh-cn"
import { useUserStore } from "@/store/modules/user"
import operate from '@/layout/components/operate/index.vue'
const { webFrame,ipcRenderer } = require("electron")
const UserStore = useUserStore()
const isLoginPage = computed(() => {
  return UserStore.isLoginPage
})

onMounted(() => {
  // 在渲染进程中监听日志消息
  ipcRenderer.on('logData', (event, logs) => {
    console.log(logs);
  });
  // ipcRenderer.on('show', () => {
  //   // 应用显示时，添加动画效果
  // });
  // ipcRenderer.on('hide', () => {
  //   // 应用隐藏时，添加动画效果
  // });
  window.vIpcRenderer.once("zoom_win", (_, scale: number) => webFrame.setZoomFactor(scale))
  window.vIpcRenderer.once("get_title", (_, args: string) => {
    const style1 = "color: #fff; background: #41b883; padding: 4px; border-radius: 4px;"
    const style2 = "color: #fff; background: #409EFF; padding: 4px 8px; border-radius: 4px;"
    console.log(`%c Hi! %c${args}@v${window.CLIENT_VERSION}`, style1, style2)
  })
  let params:object = {}
  /** 设置窗口 */
  if (isLoginPage) {
    params = {
      width: 400,
      height: 500,
      center: true,
      maxable: true,//false,即为禁用最大化按钮
      resizable: false
    }
  }else{
    params = {
      width: 1200,
      height: 800,
      center: true,
      maxable: true,
      resizable: true
    }
  }
  window.vIpcRenderer.send("set_win_size", params)
  /** 打印 应用标题与版本号 */
  window.vIpcRenderer.send("query_title")
})

/** 初始化主题 */
const { initTheme } = useTheme()
initTheme()
/** 将 Element Plus 的语言设置为中文 */
const locale = zhCn
/** 欢迎 star 标语 */
// ElNotification({
//   title: "Hello",
//   message: h(
//     "a",
//     { style: "color: teal", target: "_blank", href: "https://github.com/un-pany/v3-admin-vite" },
//     "小项目获取 star 不易，如果你喜欢这个项目的话，欢迎点击这里支持一个 star ！这是作者持续维护的唯一动力（小声：毕竟是免费的）"
//   ),
//   duration: 0,
//   position: "bottom-right"
// })

// end
</script>

<template>
  <div class="box">
    <div v-if="isLoginPage" class="topMenu ">
      <operate/>
    </div>
    <div class="routerEntry">
     <!-- <div style="height:30px">
      <a href="http://192.168.1.61:10040/form/#/goodsList?id=4028819589aaba170189b0d88759016f&type=dispatch">12313131</a>
     </div> -->
      <ElConfigProvider :locale="locale">
        <router-view />
      </ElConfigProvider>
    </div>
  </div>
</template>
<style scoped lang="scss">
.box{
  height: 100%;
  display: flex;
  flex-direction: column;
  .routerEntry{
    flex: 1;
    background-size: cover;
    // background-image: url('https://img2.baidu.com/it/u=3865066971,1976501447&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500');
  }
  .topMenu{
    display: flex;
    justify-content: flex-end;
    padding-right:10px;
    -webkit-app-region: drag;
  }
}

/*应用显示时，添加动画效果*/
/* 定义淡入动画效果 */
</style>
